package com.wu.search.controller;

import com.wu.common.convertion.result.Result;
import com.wu.search.cache.SuggestWordCache;
import com.wu.search.service.SearchService;
import com.wu.common.convertion.result.Results;
import com.wu.search.vo.SuggestResp;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Cousin
 * @date 2025/4/9
 * @Description
 */
@RestController
@RequestMapping("search")
@RequiredArgsConstructor
public class SearchController {
    private final SearchService searchService;
    @GetMapping("suggestions")
    public Object getSuggestions(@RequestParam String keyword) {
        return Results.success(searchService.getSuggestions(keyword));
    }
    @GetMapping("all")
    public Object getAll(@RequestParam String keyword){
        return "{\n" +
                "  \"success\": true,\n" +
                "  \"data\": {\n" +
                "    \"songs\": [\n" +
                "      {\n" +
                "        \"id\": \"song-001\",\n" +
                "        \"title\": \"Blinding Lights\",\n" +
                "        \"url\": \"Blinding Lights\",\n" +
                "        \"artists\": \"The Weeknd\",\n" +
                "        \"album\": \"After Hours\",\n" +
                "        \"duration\": 200,\n" +
                "        \"cover\": \"/placeholder.svg?height=80&width=80\",\n" +
                "        \"artistId\": \"artist-001\",\n" +
                "        \"albumId\": \"album-001\",\n" +
                "        \"releaseDate\": \"2020-03-20\",\n" +
                "        \"playCount\": 15000000\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"song-002\",\n" +
                "        \"title\": \"Save Your Tears\",\n" +
                "        \"url\": \"Blinding Lights\",\n" +
                "        \"artists\": \"The Weeknd\",\n" +
                "        \"album\": \"After Hours\",\n" +
                "        \"duration\": 215,\n" +
                "        \"cover\": \"/placeholder.svg?height=80&width=80\",\n" +
                "        \"artistId\": \"artist-001\",\n" +
                "        \"albumId\": \"album-001\",\n" +
                "        \"releaseDate\": \"2020-03-20\",\n" +
                "        \"playCount\": 12000000\n" +
                "      }\n" +
                "    ],\n" +
                "    \"artists\": [\n" +
                "      {\n" +
                "        \"id\": \"artist-001\",\n" +
                "        \"name\": \"artist\",\n" +
                "        \"title\": \"The Weeknd\",\n" +
                "        \"avatar\": \"/img/avatar/2.jpg\",\n" +
                "        \"followerCount\": 25000000,\n" +
                "        \"description\": \"Canadian singer, songwriter, and record producer\",\n" +
                "        \"genres\": [\n" +
                "          \"R&B\",\n" +
                "          \"Pop\",\n" +
                "          \"Alternative R&B\"\n" +
                "        ]\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"artist-002\",\n" +
                "        \"title\": \"Dua Lipa\",\n" +
                "        \"name\": \"artist2\",\n" +
                "        \"avatar\": \"/img/avatar/3.jpg\",\n" +
                "        \"followerCount\": 18000000,\n" +
                "        \"description\": \"English singer and songwriter\",\n" +
                "        \"genres\": [\n" +
                "          \"Pop\",\n" +
                "          \"Dance\",\n" +
                "          \"Electronic\"\n" +
                "        ]\n" +
                "      }\n" +
                "    ],\n" +
                "    \"albums\": [\n" +
                "      {\n" +
                "        \"id\": \"album-001\",\n" +
                "        \"title\": \"After Hours\",\n" +
                "        \"artists\": \"The Weeknd\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"releaseDate\": \"2020-03-20\",\n" +
                "        \"songCount\": 14,\n" +
                "        \"artistId\": \"artist-001\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"album-002\",\n" +
                "        \"title\": \"Future Nostalgia\",\n" +
                "        \"artists\": \"Dua Lipa\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"releaseDate\": \"2020-03-27\",\n" +
                "        \"songCount\": 11,\n" +
                "        \"artistId\": \"artist-002\"\n" +
                "      }\n" +
                "    ],\n" +
                "    \"playlists\": [\n" +
                "      {\n" +
                "        \"id\": \"playlist-001\",\n" +
                "        \"title\": \"Top Hits 2023\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"artists\": \"Music Platform\",\n" +
                "        \"songCount\": 50,\n" +
                "        \"playCount\": 5000000,\n" +
                "        \"description\": \"The biggest hits of 2023\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"playlist-002\",\n" +
                "        \"title\": \"Chill Vibes\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"artists\": \"Music Platform\",\n" +
                "        \"songCount\": 30,\n" +
                "        \"playCount\": 2500000,\n" +
                "        \"description\": \"Relaxing tunes for your downtime\"\n" +
                "      }\n" +
                "    ],\n" +
                "    \"mvs\": [\n" +
                "      {\n" +
                "        \"id\": \"mv-001\",\n" +
                "        \"title\": \"Blinding Lights\",\n" +
                "        \"artists\": \"The Weeknd\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=350\",\n" +
                "        \"duration\": 240,\n" +
                "        \"playCount\": 8000000,\n" +
                "        \"releaseDate\": \"2020-01-21\",\n" +
                "        \"artistId\": \"artist-001\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"mv-002\",\n" +
                "        \"title\": \"Don't Start Now\",\n" +
                "        \"artists\": \"Dua Lipa\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=350\",\n" +
                "        \"duration\": 222,\n" +
                "        \"playCount\": 6500000,\n" +
                "        \"releaseDate\": \"2019-11-01\",\n" +
                "        \"artistId\": \"artist-002\"\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "}";
    }
    @GetMapping("hot")
    public Result<List<SuggestResp>> getSearchHotWord(){
        return Results.success(SuggestWordCache.getInstance().getSuggestRespList());
    }
    @GetMapping("songs")
    public Object getSongs(@RequestParam String keyword){
        return "{\n" +
                "  \"success\": true,\n" +
                "  \"data\": {\n" +
                "    \"total\": 100,\n" +
                "    \"page\": 1,\n" +
                "    \"pageSize\": 20,\n" +
                "    \"items\": [\n" +
                "      {\n" +
                "        \"id\": \"song-001\",\n" +
                "        \"title\": \"Blinding Lights\",\n" +
                "        \"artists\": \"The Weeknd\",\n" +
                "        \"duration\": 200,\n" +
                "        \"cover\": \"/placeholder.svg?height=80&width=80\",\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"song-002\",\n" +
                "        \"title\": \"Save Your Tears\",\n" +
                "        \"artists\": \"The Weeknd\",\n" +
                "        \"duration\": 215,\n" +
                "        \"cover\": \"/placeholder.svg?height=80&width=80\",\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"song-003\",\n" +
                "        \"title\": \"Don't Start Now\",\n" +
                "        \"artists\": \"Dua Lipa\",\n" +
                "        \"duration\": 183,\n" +
                "        \"cover\": \"/placeholder.svg?height=80&width=80\",\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"song-004\",\n" +
                "        \"title\": \"Levitating\",\n" +
                "        \"artists\": \"Dua Lipa\",\n" +
                "        \"duration\": 203,\n" +
                "        \"cover\": \"/placeholder.svg?height=80&width=80\",\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"song-005\",\n" +
                "        \"title\": \"Watermelon Sugar\",\n" +
                "        \"artists\": \"Harry Styles\",\n" +
                "        \"duration\": 174,\n" +
                "        \"cover\": \"/placeholder.svg?height=80&width=80\",\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "}";
    }
    @GetMapping("artists")
    public Object getArtists(@RequestParam String keyword){
        return "{\n" +
                "  \"success\": true,\n" +
                "  \"data\": {\n" +
                "    \"total\": 50,\n" +
                "    \"page\": 1,\n" +
                "    \"pageSize\": 20,\n" +
                "    \"items\": [\n" +
                "      {\n" +
                "        \"id\": \"artist-001\",\n" +
                "        \"title\": \"The Weeknd\",\n" +
                "        \"avatarUrl\": \"/placeholder.svg?height=120&width=120\",\n" +
                "        \"followerCount\": 25000000,\n" +
                "        \"description\": \"Canadian singer, songwriter, and record producer\",\n" +
                "        \"genres\": [\"R&B\", \"Pop\", \"Alternative R&B\"]\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"artist-002\",\n" +
                "        \"title\": \"Dua Lipa\",\n" +
                "        \"avatarUrl\": \"/placeholder.svg?height=120&width=120\",\n" +
                "        \"followerCount\": 18000000,\n" +
                "        \"description\": \"English singer and songwriter\",\n" +
                "        \"genres\": [\"Pop\", \"Dance\", \"Electronic\"]\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"artist-003\",\n" +
                "        \"title\": \"Harry Styles\",\n" +
                "        \"avatarUrl\": \"/placeholder.svg?height=120&width=120\",\n" +
                "        \"followerCount\": 20000000,\n" +
                "        \"description\": \"English singer, songwriter, and actor\",\n" +
                "        \"genres\": [\"Pop\", \"Rock\", \"Soft Rock\"]\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"artist-004\",\n" +
                "        \"title\": \"Billie Eilish\",\n" +
                "        \"avatarUrl\": \"/placeholder.svg?height=120&width=120\",\n" +
                "        \"followerCount\": 22000000,\n" +
                "        \"description\": \"American singer and songwriter\",\n" +
                "        \"genres\": [\"Pop\", \"Alternative\", \"Electropop\"]\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"artist-005\",\n" +
                "        \"title\": \"Taylor Swift\",\n" +
                "        \"avatarUrl\": \"/placeholder.svg?height=120&width=120\",\n" +
                "        \"followerCount\": 30000000,\n" +
                "        \"description\": \"American singer-songwriter\",\n" +
                "        \"genres\": [\"Pop\", \"Country\", \"Folk\", \"Alternative\"]\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "}";
    }
    @GetMapping("albums")
    public Object getAlbums(@RequestParam String keyword){
        return "{\n" +
                "  \"success\": true,\n" +
                "  \"data\": {\n" +
                "    \"total\": 80,\n" +
                "    \"page\": 1,\n" +
                "    \"pageSize\": 20,\n" +
                "    \"items\": [\n" +
                "      {\n" +
                "        \"id\": \"album-001\",\n" +
                "        \"title\": \"After Hours\",\n" +
                "        \"artists\": \"The Weeknd\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"songCount\": 14,\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"album-002\",\n" +
                "        \"title\": \"Future Nostalgia\",\n" +
                "        \"artists\": \"Dua Lipa\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +

                "        \"songCount\": 11,\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"album-003\",\n" +
                "        \"title\": \"Fine Line\",\n" +
                "        \"artists\": \"Harry Styles\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"songCount\": 12,\n" +

                "      },\n" +
                "      {\n" +
                "        \"id\": \"album-004\",\n" +
                "        \"title\": \"Happier Than Ever\",\n" +
                "        \"artists\": \"Billie Eilish\",\n" +
                "        \"coverUrl\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"releaseDate\": \"2021-07-30\",\n" +
                "        \"songCount\": 16,\n" +
                "        \"artistId\": \"artist-004\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"album-005\",\n" +
                "        \"title\": \"Midnights\",\n" +
                "        \"artists\": \"Taylor Swift\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"songCount\": 13,\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "}";
    }
    @GetMapping("playlists")
    public Object getPlaylists(@RequestParam String keyword){
        return "{\n" +
                "  \"success\": true,\n" +
                "  \"data\": {\n" +
                "    \"total\": 120,\n" +
                "    \"page\": 1,\n" +
                "    \"pageSize\": 20,\n" +
                "    \"items\": [\n" +
                "      {\n" +
                "        \"id\": \"playlist-001\",\n" +
                "        \"title\": \"Top Hits 2023\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"artists\": \"Music Platform\",\n" +
                "        \"songCount\": 50,\n" +
                "        \"playCount\": 5000000,\n" +
                "        \"description\": \"The biggest hits of 2023\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"playlist-002\",\n" +
                "        \"title\": \"Chill Vibes\",\n" +
                "        \"coverUrl\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"artists\": \"Music Platform\",\n" +
                "        \"songCount\": 30,\n" +
                "        \"playCount\": 2500000,\n" +
                "        \"description\": \"Relaxing tunes for your downtime\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"playlist-003\",\n" +
                "        \"title\": \"Workout Motivation\",\n" +
                "        \"coverUrl\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"artists\": \"FitnessFreak\",\n" +
                "        \"songCount\": 25,\n" +
                "        \"playCount\": 3200000,\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"playlist-004\",\n" +
                "        \"title\": \"Study Focus\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"artists\": \"StudyBuddy\",\n" +
                "        \"songCount\": 40,\n" +
                "        \"playCount\": 1800000,\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"playlist-005\",\n" +
                "        \"title\": \"Road Trip Essentials\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=200\",\n" +
                "        \"artists\": \"Traveler\",\n" +
                "        \"songCount\": 35,\n" +
                "        \"playCount\": 2100000,\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "}";
    }
    @GetMapping("mvs")
    public Object getMvs(@RequestParam String keyword){
        return "{\n" +
                "  \"success\": true,\n" +
                "  \"data\": {\n" +
                "    \"total\": 70,\n" +
                "    \"page\": 1,\n" +
                "    \"pageSize\": 20,\n" +
                "    \"items\": [\n" +
                "      {\n" +
                "        \"id\": \"mv-001\",\n" +
                "        \"title\": \"Blinding Lights\",\n" +
                "        \"artists\": \"The Weeknd\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=350\",\n" +
                "        \"duration\": 240,\n" +
                "        \"playCount\": 8000000,\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"mv-002\",\n" +
                "        \"title\": \"Don't Start Now\",\n" +
                "        \"artists\": \"Dua Lipa\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=350\",\n" +
                "        \"duration\": 222,\n" +
                "        \"playCount\": 6500000,\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"mv-003\",\n" +
                "        \"title\": \"Watermelon Sugar\",\n" +
                "        \"artists\": \"Harry Styles\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=350\",\n" +
                "        \"duration\": 208,\n" +
                "        \"playCount\": 5800000,\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"mv-004\",\n" +
                "        \"title\": \"Therefore I Am\",\n" +
                "        \"artists\": \"Billie Eilish\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=350\",\n" +
                "        \"duration\": 255,\n" +
                "        \"playCount\": 4900000,\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": \"mv-005\",\n" +
                "        \"title\": \"Anti-Hero\",\n" +
                "        \"artists\": \"Taylor Swift\",\n" +
                "        \"cover\": \"/placeholder.svg?height=200&width=350\",\n" +
                "        \"duration\": 215,\n" +
                "        \"playCount\": 7200000,\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "}";
    }

}
